package com.linfeng.component.common.exception;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;

@Data
@JsonSerialize(using = CustomExceptionSerializer.class)
public class CustomException extends RuntimeException {

    private Integer code;
    private String message;

    public CustomException(String message) {
        super(message);
        this.code = CustomExceptionCode.SYSTEM_EXCEPTION.getCode();
    }

    public CustomException(Integer code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public CustomException(CustomExceptionCode exceptionCode) {
        this.code = exceptionCode.getCode();
        this.message = exceptionCode.getDescription();
    }
}
